﻿using System;
using System.Net;
using System.Net.Mail;
using System.Web.UI;

namespace 内置对象的使用与配置
{
    public partial class SendEmail : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void btnSendEmail_Click(object sender, EventArgs e)
        {
            var client = new SmtpClient("smtp.qq.com");
            client.Credentials = new NetworkCredential("11234387@qq.com", "liuxiaozeng"); //邮箱身份验证

            var mail = new MailMessage("11234387@qq.com", "11234387@qq.com");
            mail.Subject = "hello";
            mail.Body = "aaaa";
            mail.Attachments.Add(new Attachment("c:\\total.txt"));

            client.Send(mail);
        }
    }
}